import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
      isShowPopOver:false,//控制信息修改弹出窗显隐状态
      editData:'',//传值对象-编辑前的数据值
      updateInfo:'',//数据更新状态-日期值
  },
  //获取状态树中存储的状态值
  getters:{
    getShowPopOver:(state)=>{
      return state.isShowPopOver;
    },
    getEditData:(state)=>{
      return state.editData;
    },
    getUpdateInfo:(state)=>{
      return state.updateInfo;
    }
  },
  //设置状态树中的状态值-必须同步执行
  mutations: {
    setIsShowPopOver(state,payload){
      state.isShowPopOver = payload;
    },
    setEditData:(state,payload)=>{
      state.editData = payload;
    },
    setUpdateInfo:(state,payload)=>{
      state.updateInfo = payload;
    }
  },
  //处理异步状态值-可执行异步操作
  actions: {
    setIsShowPopOverAsync({commit},payload){
      commit('setIsShowPopOver',payload);
    },
    setEditDataAsync({commit},payload){
      commit('setEditData',payload);
    },
    setUpdateInfoAsync({commit},payload){
      commit('setUpdateInfo',payload);
    }
  }
})
